package com.example.neusoft215gdh.androidpro_21.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.neusoft215gdh.androidpro_21.Listener.AlterUserInfo;
import com.example.neusoft215gdh.androidpro_21.Model.ActivityModel;
import com.example.neusoft215gdh.androidpro_21.R;
/**
 * Created by Rainbow on 2017/11/12.
 */

public class EditpersonActivity extends AppCompatActivity implements AlterUserInfo{
    private EditText Name;
    private Button queren;
    private String id,getname;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_editperson);
        Name =(EditText)findViewById(R.id.Name);
        SharedPreferences sharedPreferences=getSharedPreferences("Userid", Context.MODE_PRIVATE);
        id = sharedPreferences.getString("user_id","1");
        queren = (Button)findViewById(R.id.queren);
        queren.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                getname = Name.getText().toString();
                ActivityModel activityModel = new ActivityModel();
                activityModel.alterUserInfo(id,id,getname,EditpersonActivity.this);
            }
        });
    }

    @Override
    public void onResponse(String str) {
        if (str.equals("0")) Toast.makeText(this, "修改失败", Toast.LENGTH_SHORT).show();
        else  Toast.makeText(this, "修改成功", Toast.LENGTH_SHORT).show();

    }

    @Override
    public void onFail(String msg) {
        Toast.makeText(this, "服务器超时", Toast.LENGTH_SHORT).show();
    }
}


